from django.shortcuts import render,HttpResponse

# Create your views here.

# class
from rest_framework.viewsets import ViewSet
import redis
import datetime
from django.core.cache import cache
from utils.common_response import APIResponse
conn = redis.Redis(decode_responses=True)
from rest_framework.decorators import action
from .consumer import user_mesg_list
class MessageVue(ViewSet):
    @action(methods=['GET',], detail=False)
    def message(self, request):
        # group_num = request.query_params.get('num')
        print(1)
        tody_time = cache.get('tody_time')


        print(tody_time)
        number = conn.llen(f'{tody_time}_mesg')
        print(number,type(number))
        res = conn.lrange(f'{tody_time}_mesg',0,number)
        print(f'{res}消息记录')
        return APIResponse(data=res)

